﻿<cfsilent>
	<cfscript>
		
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		
		event.setArg("pageTitle", "成绩管理 - 成绩修订 - 添加学生成绩");
		
		studentId = event.getArg("STU");
		termId = event.getArg("TID");
		courseId = event.getArg("CID");
		
		passArgs = structNew();
		structInsert(passArgs, "STU", studentId, true);
		structInsert(passArgs, "TID", termId, true);

		currentTab = event.getArg("TabID", "labSearch");
		
		/* 搜索课程 */
		keyword = event.getArg("Keywords");
		
		rs_course = queryNew("cid");
		
		if ( len(keyword) ) {
			
			sql = "SELECT 
						t_course.cid, t_course.course_name, t_course.course_credit, t_course.period, 
						t_course.period_theory, t_course.period_practice, t_course.period_computer, 
						t_course.period_week, 
						t_institute.institute_short, 
						t_course.course_code 
					FROM 
						t_course  
						INNER JOIN t_institute ON t_institute.institute_id = t_course.institute_id 
					WHERE 
						(
							  t_course.course_name LIKE :keyword 
							  OR 
							  t_course.course_code LIKE :keyword 
						)
					ORDER BY 
						t_course.course_name ASC ";
						
			queryObj = new Query( datasource=application.dnsSlave, maxRows=30 );
			queryObj.addParam( name="keyword", value=trim(keyword) & '%', cfsqltype="cf_sql_varchar" );
			
			rs_course = queryObj.execute( sql=sql ).getResult();
		
			
			
		}
		
		if ( len(courseId) ) {
			
			currentTab = event.getArg("TabID", "labForm");
			
			sql = "SELECT 
						course_name, course_code , course_credit, mark_mode 
					FROM 
						t_course  
					WHERE 
						cid = :courseId ";
						
			queryObj = new Query( datasource=application.dnsSlave, maxRows=30 );
			queryObj.addParam( name="courseId", value=courseId, cfsqltype="cf_sql_varchar" );
			
			rs_courseEntity = queryObj.execute( sql=sql ).getResult();
			
			
			sql = "SELECT stu_id, stu_name FROM t_student WHERE stu_id = :studentId ";
		
			queryObj = new Query( datasource=application.dnsSlave );
			queryObj.addParam( name="studentId", value=studentId, cfsqltype="cf_sql_varchar" );
			
			rs_studentEntity = queryObj.execute( sql=sql ).getResult();
			
		}
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('studentMarkView', passArgs)#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">学生成绩</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 edit"></i>录入成绩
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labSearch">class="active"</cfif> id="labSearch" tabTarget="Search">搜索课程</span>
						<cfif len(courseId)>
							<span <cfif currentTab eq "labForm">class="active"</cfif> id="labForm" tabTarget="Form">录入成绩</span>
						</cfif>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				<div id="Search" class="tabContent">
				
					<form id="formSearch" onSubmit="javascript:return processVerfiyForm('formSearch');" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('studentMarkCreate', passArgs)#</cfoutput>">
						<input type="hidden" name="TabID" value="labSearch" />
						
						<div class="label">
							<b>课程或课程号</b>
							<input name="Keywords" id="Keywords" type="text" class="typeText" verification="required" maxlength="128" value="<cfoutput>#event.getArg('Keywords')#</cfoutput>" />
						</div>
						<hr/>
						<div class="lable">
							<input class="button1" type="submit" value="搜索" />
						</div>
					</form>
					
					<cfif rs_course.recordCount>

						<table id="courseList" class="UIEditable">
							<thead>
								<tr>
									<td width="18"></td>
									<td width="50">任课单位</td>
									<td width="80">课程号</td>
									<td>课程</td>
									<td width="24" align="center">学分</td>
									<td width="36" align="center">总学时</td>
									<td width="24" align="center">理论</td>
									<td width="24" align="center">实践</td>
									<td width="24" align="center">上机</td>
									<td width="36" align="center">周学时</td>
								</tr>
							</thead>
							<tbody>
                                <cfloop query="rs_course">
									<cfset structInsert( passArgs, "CID", rs_course.cid, true ) />
									<tr class="editRows">
										<td><a class="pointer" href="<cfoutput>#buildURL('studentMarkCreate', passArgs)#</cfoutput>"></a></td>
										<td><cfoutput>#rs_course.institute_short#</cfoutput></td>
										<td><span class="numeric"><cfoutput>#rs_course.course_code#</cfoutput></span></td>
										<td id="courseName<cfoutput>#rs_course.cid#</cfoutput>"><cfoutput>#rs_course.course_name#</cfoutput></td>
										<td id="courseCredit<cfoutput>#rs_course.cid#</cfoutput>"><span class="numeric"><cfoutput>#numberFormat(rs_course.course_credit, "0.0")#</cfoutput></span></td>
										<td align="right"><span class="numeric"><cfoutput>#rs_course.period#</cfoutput></span></td>
										<td align="right"><span class="numeric"><cfoutput>#rs_course.period_theory#</cfoutput></span></td>
										<td align="right"><span class="numeric"><cfoutput>#rs_course.period_practice#</cfoutput></span></td>
										<td align="right"><span class="numeric"><cfoutput>#rs_course.period_computer#</cfoutput></span></td>
										<td align="right"><span class="numeric"><cfoutput>#rs_course.period_week#</cfoutput></span></td>
									</tr>
								</cfloop>
								<cfset structDelete( passArgs, "CID", false ) />
							</tbody>
						</table>
						
					</cfif>
					
				</div>
				
				<cfif len(courseId)>
				
					<div id="Form" class="tabContent">
					
						<div class="noticeBlock">
							<h3>录入成绩</h3>
						</div>
					
						<cfif event.isArgDefined("markExistsID")>
							<div class="systemNotice">
								<p>刚才您录入的成绩已存在, 请仔细核对课程、学号及学期信息</p>
							</div>
						</cfif>
						
						
						<form id="formCreate" onSubmit="javascript:return processVerfiyForm('formCreate');" class="formWrapper" method="post" action="<cfoutput>#buildURL('studentMarkCreateDo')#</cfoutput>">
						
							<input type="hidden" name="StudentID" value="<cfoutput>#studentId#</cfoutput>" />
							<input type="hidden" name="CourseID" value="<cfoutput>#courseId#</cfoutput>" />
							
							<div class="label">
								<b>学生</b>
								<input type="text" readonly="readonly" name="StudentName" class="typeTextReadOnly" value="<cfoutput>#rs_studentEntity.stu_name#</cfoutput> - <cfoutput>#rs_studentEntity.stu_id#</cfoutput>" />
							</div>

							<div class="label">
								<b>课程</b>
								<input type="text" readonly="readonly" name="CourseName" class="typeTextReadOnly" value="<cfoutput>#rs_courseEntity.course_name#</cfoutput>" />
							</div>
							
							<div class="label">
								<b>课程号</b>
								<input type="text" readonly="readonly" name="CourseCode" class="typeTextReadOnly typeTextTiny inlinePart" value="<cfoutput>#rs_courseEntity.course_code#</cfoutput>" />
								学分
								<input type="text" readonly="readonly" name="Credit" class="typeTextReadOnly typeTextTiny inlinePart" value="<cfoutput>#numberFormat(rs_courseEntity.course_credit, '0.0')#</cfoutput>" />
								<p class="notice">
									请仔细核对课程号及课程对应的学分, 确认无误后再继续
								</p>
							</div>
							
							<hr/>
							
							<div class="label">
								<b>课程修读时间</b>
								<select class="inlinePart" name="TermY">
									<cfloop from="#(year(now())-9)#" to="#(year(now()))#" index="y">
										<option <cfif left(termId, 2) eq right(y,2)>selected="selected"</cfif> value="<cfoutput>#right(y,2)#</cfoutput>"><cfoutput>#y#</cfoutput>-<cfoutput>#y+1#</cfoutput></option>
									</cfloop>
								</select>
								学年
								<select class="inlinePart" name="TermT">
									<cfloop list="1,2" index="i">
										<option <cfif right(termId, 1) eq i>selected="selected"</cfif> value="<cfoutput>#i#</cfoutput>"><cfoutput>#dictAdvice.getTerm( i )#</cfoutput></option>
									</cfloop>
								</select>
							</div>
							
							<div class="label">
								<b>开课类别</b>
								<input name="TaskType" type="radio" class="typeRadio" value="P" <cfif event.getArg("TaskType", "P") eq "P">checked="checked"</cfif> />计划课程
								&nbsp;&nbsp;&nbsp;&nbsp;
								<input name="TaskType" type="radio" class="typeRadio" value="C" <cfif event.getArg("TaskType", "P") eq "C">checked="checked"</cfif> />全校通选课
								&nbsp;&nbsp;&nbsp;&nbsp;
								<!---<input name="TaskType" type="radio" class="typeRadio" value="T" <cfif event.getArg("TaskType", "P") eq "T">checked="checked"</cfif> />体育项目--->
							</div>
							
							<div class="label">
								<b>课程性质</b>
								<table width="400px">
									<tr>
										<td width="33%"><input name="PropID" type="radio" class="typeRadio" value="1" <cfif event.getArg("PropID", "1") eq "1">checked="checked"</cfif> />
											必修</td>
									</tr>
									<tr>
										<td><input name="PropID" type="radio" class="typeRadio" value="2" <cfif event.getArg("PropID", "1") eq "2">checked="checked"</cfif> />
											选修</td>
									
									</tr>
									<!---<tr>
										<td><input name="PropID" type="radio" class="typeRadio" value="3" <cfif event.getArg("PropID", "1") eq "3">checked="checked"</cfif> />
											全校通选课</td>
										<td>&nbsp;</td>
										<td>&nbsp;</td>
									</tr>--->
								</table>
							</div>
							
							<hr/>
							
							<div class="label">
								<b>重修标记</b>
								<input name="Retaking" type="radio" class="typeRadio" value="1" <cfif event.getArg("Retaking", "0") eq "1">checked="checked"</cfif> />是
								&nbsp;&nbsp;&nbsp;&nbsp;
								<input name="Retaking" type="radio" class="typeRadio" value="0" <cfif event.getArg("Retaking", "0") eq "0">checked="checked"</cfif> />否
								<p class="notice">请仔细核对要录入成绩是否属于重新学习课程, 如该成绩属于重修课程, 则应当选中 "是" 选项</p>
							</div>
							
							<hr/>
							
							<!--- 二级制成绩 --->
							<cfif rs_courseEntity.mark_mode eq "2">
							
								<div class="label">
									<b>正考成绩</b>
									<table>
										<tr>
											<td width="60px"><input name="MarkNote" type="radio" class="typeRadio" value="Y" <cfif event.getArg("MarkNote", "Y") eq "Y">checked="checked"</cfif> /> 合格</td>
											<td width="110px"><input name="MarkNote" type="radio" class="typeRadio" value="N" <cfif event.getArg("MarkNote", "Y") eq "N">checked="checked"</cfif> /> 不合格</td>
											<td width="60px"><input name="MarkNote" type="radio" class="typeRadio" value="2" <cfif event.getArg("MarkNote", "Y") eq "2">checked="checked"</cfif> /> 缺考</td>
											<td width="60px"><input name="MarkNote" type="radio" class="typeRadio" value="3" <cfif event.getArg("MarkNote", "Y") eq "3">checked="checked"</cfif> /> 缓考</td>
										</tr>
									</table>
								</div>
								
								<div class="label">
									<b>补考成绩</b>
									<table>
										<tr>
											<td width="60px"><input name="MarkResitNote" type="radio" class="typeRadio" value="Y" <cfif event.getArg("MarkResitNote", "0") eq "Y">checked="checked"</cfif> /> 合格</td>
											<td width="110px"><input name="MarkResitNote" type="radio" class="typeRadio" value="N" <cfif event.getArg("MarkResitNote", "0") eq "N">checked="checked"</cfif> /> 不合格</td>
											<td width="60px"><input name="MarkResitNote" type="radio" class="typeRadio" value="0" <cfif event.getArg("MarkResitNote", "0") eq "0">checked="checked"</cfif> /> 无</td>
											<td width="60px"><input name="MarkResitNote" type="radio" class="typeRadio" value="2" <cfif event.getArg("MarkResitNote", "0") eq "2">checked="checked"</cfif> /> 缺考</td>
										</tr>
									</table>
								</div>
							
							</cfif>
                                   
                                   <!--- 五级制成绩 --->
							<cfif rs_courseEntity.mark_mode eq "4">
							
								<div class="label">
									<b>正考成绩</b>
									<table>
										<tr>
											
											<td width="60px"><input name="MarkNote" type="radio" class="typeRadio" value="A" <cfif event.getArg("MarkNote", "1") eq "B">checked="checked"</cfif> /> 优</td>
											<td width="60px"><input name="MarkNote" type="radio" class="typeRadio" value="B" <cfif event.getArg("MarkNote", "1") eq "D">checked="checked"</cfif> /> 良</td>
											<td width="60px"><input name="MarkNote" type="radio" class="typeRadio" value="C" <cfif event.getArg("MarkNote", "1") eq "E">checked="checked"</cfif> /> 中</td>
											<td width="60px"><input name="MarkNote" type="radio" class="typeRadio" value="D" <cfif event.getArg("MarkNote", "1") eq "F">checked="checked"</cfif> /> 及格</td>
                                                       <td width="60px"><input name="MarkNote" type="radio" class="typeRadio" value="E" <cfif event.getArg("MarkNote", "1") eq "G">checked="checked"</cfif> /> 不及格</td>
										</tr>
									</table>
								</div>
									<input name="MarkResitNote"  class="typeRadio" value="0"  type="hidden"/>
								<!---<div class="label">
									<b>补考成绩</b>
									<table>
										<tr>
                                                  	<td width="60px"><input name="MarkResitNote" type="radio" class="typeRadio" value="A" <cfif event.getArg("MarkNote", "0") eq "0">checked="checked"</cfif> /> 无</td>
											<td width="60px"><input name="MarkResitNote" type="radio" class="typeRadio" value="A" <cfif event.getArg("MarkNote", "0") eq "A">checked="checked"</cfif> /> 优+</td>
											<td width="60px"><input name="MarkResitNote" type="radio" class="typeRadio" value="B" <cfif event.getArg("MarkNote", "0") eq "B">checked="checked"</cfif> /> 优</td>
											<td width="60px"><input name="MarkResitNote" type="radio" class="typeRadio" value="C" <cfif event.getArg("MarkNote", "0") eq "C">checked="checked"</cfif> /> 良+</td>
											<td width="60px"><input name="MarkResitNote" type="radio" class="typeRadio" value="D" <cfif event.getArg("MarkNote", "0") eq "D">checked="checked"</cfif> /> 良</td>
											<td width="60px"><input name="MarkResitNote" type="radio" class="typeRadio" value="E" <cfif event.getArg("MarkNote", "0") eq "E">checked="checked"</cfif> /> 中</td>
											<td width="60px"><input name="MarkResitNote" type="radio" class="typeRadio" value="F" <cfif event.getArg("MarkNote", "0") eq "F">checked="checked"</cfif> /> 及格</td>
                                                       <td width="60px"><input name="MarkResitNote" type="radio" class="typeRadio" value="G" <cfif event.getArg("MarkNote", "0") eq "G">checked="checked"</cfif> /> 不及格</td>
										</tr>
									</table>
								</div>--->
							
							</cfif>
							
							<!--- 百分制成绩 --->
							<cfif rs_courseEntity.mark_mode eq "0">
								
								<div class="label">
									<b>正考成绩</b>
									<input name="Mark" type="text" class="typeTinyInt <cfif event.getArg("MarkNote", "1") neq "1">typeDisable</cfif>" <cfif event.getArg("MarkNote", "1") neq "1">disabled="disabled"</cfif> verification="double" maxlength="5" value="<cfoutput>#event.getArg('Mark', 0)#</cfoutput>" />
								</div>
								
								<div class="label">
									<b>正考成绩备注</b>
									<table width="320px">
										<tr>
											<td><input onclick="changeScroll('1');" name="MarkNote" type="radio" class="typeRadio" value="1" <cfif event.getArg("MarkNote", "1") eq "1">checked="checked"</cfif> /> 正常</td>
											<td><input onclick="changeScroll('2');" name="MarkNote" type="radio" class="typeRadio" value="2" <cfif event.getArg("MarkNote", "1") eq "2">checked="checked"</cfif> /> 缺考</td>
											<td><input onclick="changeScroll('3');" name="MarkNote" type="radio" class="typeRadio" value="3" <cfif event.getArg("MarkNote", "1") eq "3">checked="checked"</cfif> /> 缓考</td>
										</tr>
									</table>
								</div>
								
								
								<div class="label">
									<b>补考成绩</b>
									<input name="MarkResit" type="text" class="typeTinyInt <cfif event.getArg("MarkResitNote") neq "1">typeDisable</cfif>" <cfif event.getArg("MarkResitNote") neq "1">disabled="disabled"</cfif> verification="double" maxlength="5" value="<cfoutput>#event.getArg('MarkResit', '0')#</cfoutput>" />
								</div>
								
								<div class="label">
									<b>补考成绩备注</b>
									<table width="220px">
										<tr>
											<td><input onclick="changeResitScroll('0');" name="MarkResitNote" type="radio" class="typeRadio" value="0" <cfif event.getArg("MarkResitNote", "0") eq "0">checked="checked"</cfif> /> 无</td>
											<td><input onclick="changeResitScroll('1');" name="MarkResitNote" type="radio" class="typeRadio" value="1" <cfif event.getArg("MarkResitNote", "0") eq "1">checked="checked"</cfif> /> 正常</td>
											<td><input onclick="changeResitScroll('2');" name="MarkResitNote" type="radio" class="typeRadio" value="2" <cfif event.getArg("MarkResitNote", "0") eq "2">checked="checked"</cfif> /> 缺考</td>
										</tr>
									</table>
								</div>
								
								<script language="javascript" type="text/javascript">
									//<![CDATA[
									<!--
									function changeScroll( markNote ) {

										var $input = $("input[name='Mark']");
					
										switch(markNote) {
											case "1":
												$input.val("").removeAttr("disabled").removeClass("typeDisable");
												break;
											case "2":
											case "3":
											case "4":
											case "9":
												$input.val("0").attr("disabled", "disabled").addClass("typeDisable");
												break;
										}
									}
									
									function changeResitScroll( markNote ) {

										var $input = $("input[name='MarkResit']");
					
										switch(markNote) {
											case "1":
												$input.val("").removeAttr("disabled").removeClass("typeDisable");
												break;
											case "0":
											case "2":
											case "9":
												$input.val("0").attr("disabled", "disabled").addClass("typeDisable");
												break;
										}
									}
									
									// -->
									//]]>
								</script>
								
							</cfif>
							
							<hr/>
						
							<div class="lable">
								<input class="button" type="submit" value="添加" />
							</div>
							
						</form>
					
					</div>
					
				</cfif>
				
			</div>
		</li>
	</ul>
</div>
